Boolean metrics: fix formatting and exclude from fitness; README badges#473
Merged
codelion merged 3 commits intoJul 18, 2026
Conversation
codelion
marked this pull request as ready for review
July 18, 2026 12:26
…badges; bump 0.3.2
Builds on the boolean display fix in this PR. `bool` is a subclass of `int`, so the
naive `isinstance(value, (int, float))` check treats True/False as 1.0/0.0. The PR
fixed that for formatting; the same trap was still live in the FITNESS math, which
matters more:
- openevolve/utils/metrics_utils.py: exclude bools in both safe_numeric_average()
and get_fitness_score(). openevolve/evaluator.py returns {"error": 0.0,
"timeout": True} when an evaluation times out, which averaged to 0.5 - handing a
program that failed outright a mid-range fitness and letting it compete for
survival in the database. It now correctly scores 0.0.
- openevolve/controller.py: remove the module-level _format_metrics/_format_improvement
helpers. They were dead code (defined, never called - the controller imports the
shared format_utils versions), and confusingly they already contained the bool fix
that the live code path lacked. With format_utils corrected they are redundant.
- tests/test_boolean_metrics.py: covers both display and fitness. The fitness cases
fail without the metrics_utils change (0.5 != 0.0), and the suite pins that
combined_score precedence, feature-dimension exclusion, and ordinary numeric
metrics are unaffected.
README: swap the PyPI downloads badge for the pepy.tech monthly badge, and drop the
GitHub stars badge (GitHub already displays the star count).
Bump version to 0.3.2.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
boolis a subclass ofint, so a naiveisinstance(value, (int, float))check silently treatsTrue/Falseas1.0/0.0. This PR fixes that in both places it bites.This is not a hypothetical input: OpenEvolve's own evaluator emits
timeout: Trueas a metric in several places (openevolve/evaluator.py).1. Formatting (original PR)
timeout=Trueinstead of a meaninglesstimeout=1.0000.False → Trueis not a+1.0000improvement.2. Fitness math (added)
The same trap was still live in the scoring path, which matters considerably more than display. When an evaluation times out,
evaluator.pyreturns:{"error": 0.0, "timeout": True}safe_numeric_averageaveraged that to 0.5, so a program that failed outright received a mid-range fitness and competed for survival in the database. Bothsafe_numeric_average()andget_fitness_score()now exclude booleans, and it correctly scores 0.0.3. Dead code removal
controller.pydefined module-level_format_metrics/_format_improvementthat were never called (the controller imports the sharedformat_utilsversions). Confusingly, those dead copies already contained the bool fix that the live path lacked. Withformat_utilscorrected they are redundant, so they are removed.4. README
Swap the PyPI downloads badge for the pepy.tech monthly badge, and drop the GitHub stars badge (GitHub already shows the star count).
Tests
tests/test_boolean_metrics.pycovers formatting and fitness. The fitness assertions fail without themetrics_utilschange (0.5 != 0.0), and the suite also pins thatcombined_scoreprecedence, feature-dimension exclusion, and ordinary numeric metrics are unaffected.Full suite: 413 passed.
Bumps version to 0.3.2.